<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>房产模块-报备</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox" id="tool">
		<div class="layui-inline">
			<label class="layui-input-inline">楼盘名称</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="itemName" placeholder="请输入楼盘名称" /></label>
			<label class="layui-input-inline">客户姓名</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="name" placeholder="请输入客户姓名" /></label>
			<label class="layui-input-inline">客户电话</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="phone" placeholder="请输入客户电话" /></label>
			<label class="layui-input-inline">报备状态</label>
			<label class="layui-input-inline">
				<select name="reportState" id="reportState"></select>
			</label>
			<a class="layui-btn search_btn" lay-submit="" lay-filter="seacherBtn">搜索</a></div>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/html" id="entityBar">
	<a class = "layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit"> 编辑 </a>
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a >
</script>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['jquery', 'pageUtil', 'table', 'dateUtil','dialogUtil','baseUtil'],
    function() {
        var $ = layui.jquery,
            dateUtil = layui.dateUtil,
            dialogUtil = layui.dialogUtil,
            baseUtil = layui.baseUtil,
            table = layui.table,
            pageUtil = layui.pageUtil;
        var tableIns = null;
        pageUtil.initDict("host_report_state,base_sex",
            function(dictData) {
                pageUtil.showDict($("#reportState"), pageUtil.aceeptDictContentList(dictData, "host_report_state"), "请选择报备状态");
                var url = "/hostReport/page";
                var cols = [{
                    type: 'checkbox',
                    fixed: 'left'
                },
                    {
                        type: 'numbers',
                        title: '序号'
                    },
                    {
                        field: 'itemName',
                        title: '楼盘名称',
                        align: 'center'
                    },
                    {
                        field: 'name',
                        title: '客户姓名',
                        align: 'center'
                    },
                    {
                        field: 'sex',
                        title: '性别',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictData, 'base_sex', d.sex);
                        }
                    },
                    {
                        field: 'phone',
                        title: '客户电话',
                        align: 'center'
                    },
                    {
                        field: 'idCard',
                        title: '客户身份证',
                        align: 'center',
						width:200
                    },
                    {
                        field: 'setUpBusiness',
                        title: '经纪人',
                        align: 'center',
                        width:200
                    },
                    {
                        field: 'useTime',
                        title: '预计到访时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            return dateUtil.formatDate(new Date(d.useTime), "yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        field: 'reportState',
                        title: '报备状态',
                        align: 'center',
                        templet: function(d) {
                            return pageUtil.aceeptDictContentName(dictData, 'host_report_state', d.reportState);
                        }
                    },
                    {
                        field: 'allMoney',
                        title: '总价/元',
                        align: 'center'
                    },
                    {
                        field: 'feeMoney',
                        title: '总价/元',
                        align: 'center'
                    },
                    {
                        field: 'remarks',
                        title: '客户留言',
                        align: 'center'
                    },
                    {
                        field: 'createTime',
                        title: '创建时间',
                        width: 190,
                        align: 'center',
                        templet: function(d) {
                            return dateUtil.formatDate(new Date(d.createTime), "yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        title: '操作',
                        width: 360,
                        align: "center",
                        fixed: 'right',
                        templet: function(d) {
                            //报备状态：1、报备成功，2、客户到访，3、认购成功，4、无效客户
                            if (d.reportState == "1"){
                                return '<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 报备成功 </a>\
                                <a class="layui-btn cy-btnbg-edit layui-btn-sm " lay-event="edit"> 客户到访 </a>\
                        			<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 认购成功 </a>\
                        			<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="wxEdit"> 无效客户 </a>';
                            } else if (d.reportState == "2"){
                                return '<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 报备成功 </a>\
                                <a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 客户到访 </a>\
                       				<a class="layui-btn cy-btnbg-edit layui-btn-sm " lay-event="edit2"> 认购成功 </a>\
                       				<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="wxEdit"> 无效客户 </a>';
                            } else if (d.reportState == "3") {
                                return '<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 报备成功 </a>\
                                <a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 客户到访 </a>\
									<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 认购成功 </a>\
									<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="wxEdit"> 无效客户 </a>';
                            } else if (d.reportState == "4") {
                                return '<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 报备成功 </a>\
                                <a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 客户到访 </a>\
									<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 认购成功 </a>\
									<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="wxEdit"> 无效客户 </a>';
                            } else if (d.reportState == "5") {
                                return '<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="bbEdit"> 报备成功 </a>\
                                <a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 客户到访 </a>\
									<a class="layui-btn cy-btnbg-edit layui-btn-sm layui-btn-disabled" > 认购成功 </a>\
									<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="wxEdit"> 无效客户 </a>';
                            }
                        }
                    }];
                tableIns = pageUtil.initDate(cols, url, true);
            });
        table.on('tool(entityList)',
            function(obj) {
                var layEvent = obj.event,
                    d = obj.data;
                if (layEvent === 'bbEdit') {
                    //报备状态：1、报备成功，2、客户到访，3、认购确认，4、无效客户,5、报备审核
                    dialogUtil.confirm('您确定【'+d.name+'】报备成功吗？',function(){
                        baseUtil.postMethodResult("/hostReport/update",{"reportState":"1","id":d.id},function (data) {
                            dialogUtil.alert("操作成功");
                            tableIns.reload();
                        });
                    },function(){
                    });
                }else if (layEvent === 'edit') {
                    //报备状态：1、报备成功，2、客户到访，3、认购确认，4、无效客户,5、报备审核
                    dialogUtil.confirm('您确定【'+d.name+'】为客户到访吗？',function(){
                        baseUtil.postMethodResult("/hostReport/update",{"reportState":"2","id":d.id},function (data) {
                            dialogUtil.alert("操作成功");
                            tableIns.reload();
                        });
                    },function(){
                    });
                }else if (layEvent === 'edit2') {
                    var state="3";
                    var index = layer.open({
                        type: 1,
                        title:'认购确认',
                        area: ['300px', 'auto'], //宽高
                        btn:['确定','取消'],
                        content: '<div style="padding: 15px !important;">'+
                        '<form class="layui-form">' +
                        '<div class="layui-form-item layui-row layui-col-xs12">'+
                        '<label class="layui-form-label">'+
                        '<span class="red">*</span>&nbsp;&nbsp;总价</label>'+
                        '<div class="layui-input-block">'+
                        '<input type="text" class="layui-input" style="width:100px;" id="allMoney" name="allMoney" lay-verify="required" autocomplete="off" /></div>'+
                        '</div>'+
                        '<div class="layui-form-item layui-row layui-col-xs12">'+
                        '<label class="layui-form-label">'+
                        '<span class="red">*</span>&nbsp;&nbsp;佣金</label>'+
                        '<div class="layui-input-block">'+
                        '<input type="text" class="layui-input" style="width:100px;" id="feeMoney" name="feeMoney"  lay-verify="required" autocomplete="off" /></div>'+
                        '</div>'+
                        '</form>'+
                        '</div>'
                        ,success:function(){
                        }
                        ,yes:function (){
                            var allMoney = $("#allMoney").val();
                            if(allMoney==null||allMoney==""){
                                dialogUtil.alert("请输入总价");
                                return false;
                            }
                            var feeMoney = $("#feeMoney").val();
                            if(feeMoney==null||feeMoney==""){
                                dialogUtil.alert("请输入佣金");
                                return false;
                            }
                            dialogUtil.confirm('您确定【'+d.name+'】房屋总金额为'+allMoney+'元且佣金为'+feeMoney+'元吗？',function(){
                                layer.close(index);
                                baseUtil.postMethodResult("/hostReport/update",{"reportState":state,"allMoney":allMoney,"feeMoney":feeMoney,"id":d.id},function (data) {
                                    dialogUtil.alert("操作成功");
                                    tableIns.reload();
                                });
                            },function(){
                            });
                        }
                        ,btn2: function(index, layero){

                        }
                    });
                }else if (layEvent === 'wxEdit') {
                    dialogUtil.confirm('您确定【'+d.name+'】为无效客户吗？',function(){
                        baseUtil.postMethodResult("/hostReport/update",{"reportState":"4","id":d.id},function (data) {
                          dialogUtil.alert("操作成功");
                            tableIns.reload();
                        });
                    },function(){
                    });
                }
            });
    })</script>
</body>

</html>